package indi.zhifa.recipe.bailan.framework.auth.service.impl;

import indi.zhifa.recipe.bailan.framework.auth.dao.service.IAuthNodeRelevantDao;
import indi.zhifa.recipe.bailan.framework.auth.dao.service.IUserRelevantDao;
import indi.zhifa.recipe.bailan.framework.auth.entity.po.BaseRelUserRoleEntity;
import indi.zhifa.recipe.bailan.framework.auth.entity.po.RelUserRoleEntity;
import indi.zhifa.recipe.bailan.framework.auth.service.IUserAuthService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class UserAuthServiceImpl extends BaseUserAuthServiceImpl implements IUserAuthService {

    public UserAuthServiceImpl(IAuthNodeRelevantDao pDepartmentRelevantDao,
                               IUserRelevantDao pUserRelevantDao){
        super(pDepartmentRelevantDao,pUserRelevantDao);
    }

    @Override
    public List<RelUserRoleEntity> assignRolesWithCode(Long pUserId, List<String> pRoleCodes) {
        List<BaseRelUserRoleEntity> baseRelUserRoleEntityList = super.baseAssignRolesWithCode(pUserId,pRoleCodes);
        List<RelUserRoleEntity> rtn = baseRelUserRoleEntityList.stream().map(baseRelUserRoleEntity -> (RelUserRoleEntity)baseRelUserRoleEntity).collect(Collectors.toList());
        return rtn;
    }

    @Override
    public List<RelUserRoleEntity> assignRolesWithId(Long pUserId, List<Long> pRoleIds) {
        List<BaseRelUserRoleEntity> baseRelUserRoleEntityList = super.baseAssignRolesWithId(pUserId,pRoleIds);
        List<RelUserRoleEntity> rtn = baseRelUserRoleEntityList.stream().map(baseRelUserRoleEntity -> (RelUserRoleEntity)baseRelUserRoleEntity).collect(Collectors.toList());
        return rtn;
    }

}
